home *** CD-ROM | disk | FTP | other *** search
/ Crosscountry USA Photo Safari / Crosscountry USA Photo Safari.iso / Data / cc_base / pak00_16bit_f.pk3 / eat.tab.p < prev    next >
Text File  |  2003-01-03  |  14KB  |  389 lines

  1. {
  2.   X = 601;
  3.   Y = 65;
  4.   state = 0;
  5.   rest_x = 601;
  6.   expand_x = 400;
  7.   Hidden = 1;
  8.   
  9.   ChildID = {
  10.     GuiLayer("eat_layer") {
  11.       X = 0;
  12.       Y = 0;    
  13.       ChildID = {
  14.         GuiAnimation("plate") {
  15.           X = 39;
  16.           AnimationID = "gui/dash/tab/plate/plate.pcx";
  17.           Width = 240;
  18.           Height = 180;
  19.         }, 
  20.         
  21.         
  22.             GuiTextInput("hunger_message") {
  23.           X = 45;
  24.           Y = 10;
  25.           InputDisabled = TRUE;
  26.           WordWrap = TRUE;
  27.           Width = 180;
  28.           Height = 44;
  29.           FontID = "font/verdana_9.tf";
  30.           ScriptID = Script {
  31.             @animate { 
  32.               resid Player;
  33.               resid Game;
  34.               resid hunger_data_id;
  35.               
  36.               int row_count;
  37.               str hunger_state;
  38.               int last_ate;
  39.               int time;
  40.               int hunger;
  41.               int message_row;
  42.  
  43.               hunger_data_id = ResPropGetResID(ResByName("CSVData"), "hunger_id");
  44.               Game = ResByName("Game");
  45.               Player = ResPropGetResID(Game,"game_cur_player");
  46.  
  47.               /* if we can stop here, show appropriate options below */
  48.               if (ResPropGetInt(Player,"nav_can_eat") == 1) {
  49.                 ResPropSetInt(GuiSiblingByName("can_eat_layer"),"Hidden",FALSE);
  50.                 ResPropSetInt(GuiSiblingByName("cannot_eat_layer"),"Hidden",TRUE);
  51.               } else {
  52.                 ResPropSetInt(GuiSiblingByName("can_eat_layer"),"Hidden",TRUE);
  53.                 ResPropSetInt(GuiSiblingByName("cannot_eat_layer"),"Hidden",FALSE);               
  54.               }
  55.  
  56.               last_ate = ResPropGetInt(Player,"player_last_meal");
  57.               time     = ResPropGetInt(Player,"time_now");
  58.               last_ate = ((time - last_ate) / 60) / 60; 
  59.  
  60.               hunger = ResPropGetInt(Player,"player_hunger");
  61.               row_count = CSVGetRowCount(hunger_data_id);
  62.             
  63.               message_row = (row_count * hunger) / ResPropGetInt(Game,"game_hunger_limit");   
  64.  
  65.               if (message_row > (row_count-1)) {
  66.                 message_row = row_count -1;
  67.               }
  68.               
  69.               hunger_state = CSVGetStr(hunger_data_id,"phrase",message_row);
  70.               
  71.  
  72.               
  73.               ResPropSetStr(SELF,"InputText",
  74.                 StrFormatStr(
  75.                  MangleSIDToStr(61/*"You last ate %d hours ago. %s."*/),
  76.                  last_ate,
  77.                  hunger_state
  78.                 )
  79.               );
  80.             }
  81.           };
  82.         },
  83.         GuiAnimation("line") {
  84.           AnimationID = "gui/dash/tab/line/line.pcx";
  85.           Y = 48;
  86.           X = 45;
  87.         },
  88.         
  89.         GuiLayer("can_eat_layer") {
  90.           X = 48;    
  91.           Y = 53;
  92.           ChildID = {
  93.             GuiButton("eat_button") {
  94.               X = 45;
  95.               Y = 40;
  96.               TextID = Mangle(62/*"Eat Here"*/);
  97.               StyleID = "gui/dash/tab/button/tab.gbs";
  98.               FontID = "font/tab_button.tf";
  99.               Width = 80;
  100.               AutoSize = Height;
  101.               ScriptID = Script {
  102.                 @activate { 
  103.                   resid Player;
  104.                   resid Game;
  105.                   resid RouteData;
  106.                   resid csv_data_id;
  107.                   resid city_data_id;     
  108.                   resid state_data_id;
  109.                   resid Message;
  110.                   str city;
  111.                   int meal_cost;
  112.                   int tax;
  113.                   int city_row;
  114.                   int time_now;
  115.                   str state_abbrev;
  116.     
  117.                   Game = ResByName("Game");
  118.                   Message = ResByName("dash.gl/message");
  119.  
  120.                   csv_data_id = ResByName("CSVData");
  121.                   city_data_id = ResPropGetResID(csv_data_id, "city_id");
  122.                   state_data_id = ResPropGetResID(csv_data_id, "state_id");
  123.  
  124.                   Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  125.   
  126.                   city = ResPropGetStr(Player,"nav_cur_city");
  127.                   meal_cost = ResPropGetInt(Game,"game_meal_cost");
  128.                   ResPropAlias(Player,"time_now","time_now");
  129.                   
  130.                   if (ResPropGetInt(Player,"player_hunger") == 0) {
  131.                     ResPropSetStr(Message, "InputText", MangleSIDToStr(63/*"You are too full to eat."*/));                  
  132.                     ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 5); 
  133.                     stop;
  134.                   }
  135.                   
  136.                   /* reset the last ate timer */
  137.                   ResPropSetInt(Player,"player_last_meal",ResPropGetInt(Player,"time_now"));
  138.                   
  139.                   city_row = CSVSearch(city_data_id,"name",city);
  140.                   state_abbrev = CSVGetStr(city_data_id,"state",city_row);
  141.                   tax = StrToInt(
  142.                           CSVGetStr( state_data_id,"food_tax",
  143.                             CSVSearch(state_data_id,"abbreviation",state_abbrev)
  144.                           )
  145.                         );
  146.                   
  147.                   tax = tax + 10000;
  148.                   meal_cost = (meal_cost * tax) / 10000;
  149.                   
  150.                   ResPropSetStr(Player, "nav_picture", "restaurant");
  151.                   ResPropSetStr(Player, "nav_sound",   "restaurant");
  152.                   ResPropSetInt(Player, "truck_seatbelt", 0); 
  153.                   ResParseEvent(ResByName("dash.gl/seatbelt"),"@show");
  154.                   
  155.                   /* if im on the road */
  156.                   if (ResPropGetInt(Player,"nav_at_city") == 0) {
  157.                     ResPropSetInt(Player, "nav_picture_no_dash_flag", 1);
  158.                   }
  159.  
  160.                   /* show the restaurant */
  161.                   ResPropSetInt(ResByName("dash.gl/full_screen"), "Hidden", FALSE);
  162.  
  163.                   /* add time for eating */
  164.                   time_now += ResPropGetInt(Game,"game_time_taken_to_eat");
  165.                   
  166.                   ResPropSetInt(Player,"expense_spent_on_food", ResPropGetInt(Player,"expense_spent_on_food") + meal_cost);
  167.                   ResPropSetInt(Player,"player_hunger",0);
  168.                   
  169.                   
  170.                   ResPropSetStr(Message, "InputText",
  171.                     StrFormatStr(
  172.                      MangleSIDToStr(64/*"You ate at a restaurant. The meal cost you $%s."*/),
  173.                      IntToDecimalStr(meal_cost,100)
  174.                     )
  175.                   );                  
  176.                   
  177.                   ResPropSetInt(Message, "timeout", CVarGetInt("framerate") * 10);  
  178.                 }
  179.               }
  180.             },          
  181.                 GuiTextInput("eat_message") {
  182.               Y = 0;
  183.               X = 0;
  184.               InputDisabled = TRUE;
  185.               WordWrap = TRUE;
  186.               Width = 180;
  187.               Height = 44;
  188.               FontID = "font/tab_w_on_g.tf";
  189.               ScriptID = Script {
  190.                 @animate { 
  191.                   resid Player;
  192.                   resid Game;
  193.                   resid RouteData;
  194.                   resid csv_data_id;
  195.                   resid city_data_id;      
  196.                   resid state_data_id;         
  197.                   str city;
  198.                   int meal_cost;
  199.                   int tax;
  200.                   int city_row;
  201.                   str state_abbrev;
  202.     
  203.                   Game = ResByName("Game");
  204.                   Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  205.  
  206.                   csv_data_id = ResByName("CSVData");
  207.                   city_data_id = ResPropGetResID(csv_data_id, "city_id");
  208.                   state_data_id = ResPropGetResID(csv_data_id, "state_id");   
  209.    
  210.                   city = ResPropGetStr(Player,"nav_cur_city");
  211.                   meal_cost = ResPropGetInt(Game,"game_meal_cost");
  212.                   
  213.                   city_row = CSVSearch(city_data_id,"name",city);
  214.                   state_abbrev = CSVGetStr(city_data_id,"state",city_row);
  215.                   tax = StrToInt(
  216.                           CSVGetStr( state_data_id,"food_tax",
  217.                             CSVSearch(state_data_id,"abbreviation",state_abbrev)
  218.                           )
  219.                         );
  220.                   
  221.                   tax = tax + 10000;
  222.                   meal_cost = (meal_cost * tax) / 10000;
  223.     
  224.                   ResPropSetStr(SELF,"InputText",
  225.                     StrFormatStr(
  226.                      MangleSIDToStr(65/*"The cost for a meal in %s is $%s."*/),
  227.                      city,
  228.                      IntToDecimalStr(meal_cost,100)
  229.                     )
  230.                   );
  231.                 }
  232.               };
  233.             }
  234.           };
  235.         },  
  236.  
  237.         GuiLayer("cannot_eat_layer") {
  238.           X = 48;
  239.           Y = 53;    
  240.           ChildID = {
  241.                 GuiTextInput("no_eat_message") {
  242.               X = 0;
  243.               Y = 0;
  244.               InputDisabled = TRUE;
  245.               WordWrap = TRUE;
  246.               Width = 180;
  247.               Height = 80;
  248.               FontID = "font/tab_w_on_g.tf";
  249.               ScriptID = Script {
  250.                 @animate {
  251.                   ResPropSetStr(SELF,"InputText",MangleSIDToStr(66/*"There are no restaurants here. Try driving to the next city."*/));
  252.                 }
  253.               };
  254.             }
  255.           };
  256.         },
  257.         
  258.               
  259.         GuiAnimation("line1") {
  260.           AnimationID = "gui/dash/tab/line/line.pcx";
  261.           Y = 142;
  262.           X = 45;
  263.         },
  264.             GuiTextInput("state_tax") {
  265.           X = 45;
  266.           Y = 144;
  267.           Width = 185;
  268.           Height = 35;
  269.           WordWrap = TRUE;
  270.           InputDisabled = TRUE;
  271.           FontID = "font/verdana_9.tf";
  272.           ScriptID = Script {
  273.             @animate {
  274.               resid Player;
  275.               resid Game;
  276.               resid csv_data_id;
  277.               resid city_data_id;
  278.               resid state_data_id;
  279.               str state_name;
  280.               int state_tax;
  281.               int state_row;
  282.               str state_ab;
  283.               Game = ResByName("Game");
  284.  
  285.               csv_data_id = ResByName("CSVData");
  286.               city_data_id = ResPropGetResID(csv_data_id, "city_id");
  287.               state_data_id = ResPropGetResID(csv_data_id, "state_id");
  288.  
  289.               Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  290.               state_ab = CSVGetStr(city_data_id,"state",CSVSearch(city_data_id,"name",ResPropGetStr(Player,"nav_cur_city")));
  291.               state_row = CSVSearch(state_data_id,"abbreviation",state_ab);
  292.               state_name = CSVGetStr(state_data_id,"name",state_row);
  293.               state_tax  = CSVGetInt(state_data_id,"food_tax",state_row) / 100;
  294.               ResPropSetStr(SELF,"InputText",StrFormatStr(MangleSIDToStr(67/*"%s has a food tax of %d percent."*/), state_name, state_tax ));
  295.             }
  296.           };
  297.         }     
  298.       };
  299.     },
  300.  
  301.     GuiAnimation("tab") {
  302.       Y = 82; 
  303.       AnimationID = "gui/dash/tab/eat/eat_off.pcx";
  304.       ScriptID = script {
  305.         @activate {
  306.           resid Parent;
  307.           resid Player;
  308.           resid Game;
  309.           Game = ResByName("Game");
  310.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  311.           Parent = GuiParent(SELF);
  312.           
  313.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  314.             ResPropSetResID(Player,"truck_tab_expanded",RES_INVALID);
  315.           } else {
  316.             ResPropSetResID(Player,"truck_tab_expanded",Parent);
  317.             GuiToFront(Parent);
  318.           }
  319.           
  320.           
  321.           if (ResPropGetInt(Player,"nav_can_eat") == 1) {
  322.           
  323.             ResParseEvent(ResByName("dash.gl/brake_pedal"),"@activate");
  324.           }
  325.         }
  326.  
  327.         @animate {
  328.           resid Parent;
  329.           int state;
  330.           resid Player;
  331.           resid Game;
  332.           
  333.           Game = ResByName("Game");
  334.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");          
  335.           Parent = GuiParent(SELF);
  336.  
  337.           /* if we can stop here, highlight me */
  338.           if (ResPropGetInt(Player,"nav_can_eat") == 1) {
  339.             if (ResPropGetInt(Player,"player_hunger") <= 100 ) {
  340.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/eat/eat_off.pcx"));
  341.             } else {
  342.               ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/eat/eat_on.pcx")); 
  343.             }
  344.           } else {
  345.             ResPropSetResID(SELF,"AnimationID",ResByName("gui/dash/tab/eat/eat_off.pcx"));          
  346.           }
  347.  
  348.           if ( ResPropGetResID(Player,"truck_tab_expanded") == Parent) {
  349.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"expand_x"));
  350.             ResPropSetInt(GuiSiblingByName("eat_layer"),"Hidden",FALSE);
  351.           } else {
  352.             ResPropSetInt(GuiSiblingByName("eat_layer"),"Hidden",TRUE);
  353.             ResPropSetInt(Parent,"X",ResPropGetInt(Parent,"rest_x"));
  354.           }
  355.         }
  356.       }
  357.       },
  358.     GuiAnimation("guage") {
  359.       AnimationID = "gui/dash/tab/tab_gauge/tab_gauge.anm";
  360.       Y = 85;
  361.       X = 5;
  362.      ScriptID = script {
  363.         @animate {
  364.           resid Player;
  365.           resid Game;
  366.           int frame_count;
  367.           int player_hunger;
  368.           int frame;
  369.           Game = ResByName("Game");
  370.           Player = ResPropGetResID(ResByName("Game"),"game_cur_player");
  371.           frame_count = ResPropGetInt(SELF, "FrameCount");
  372.           player_hunger = ResPropGetInt(Player,"player_hunger");
  373.  
  374.           frame_count -= 1;
  375.           frame = (frame_count * player_hunger) / ResPropGetInt(Game,"game_hunger_limit");
  376.           frame = frame_count - frame;
  377.  
  378.  
  379.           if (frame < 0) {
  380.             frame = 0;
  381.           }
  382.  
  383.           ResPropSetInt(SELF,"CurrentFrame",frame);
  384.         }
  385.       };
  386.     }
  387.   };
  388. }
  389.